
export default class VNode {
    constructor(tag, data, children, text, elm, context, componentOptions,asyncFactory) {
        this.tag = tag
        this.data = data
        this.children = children
        this.text =text
        this.elm = elm
        this.context = context
        this.componentOptions = componentOptions
        this.asyncFactory = asyncFactory
        this.isComment = false //注释节点？
    }
}

export const createEmptyVNode = (text) => {
    const node = new VNode()
    node.text = text
    node.isComment = true
}

export function createTextVNode(val) {
    return new VNode(undefined, undefined, undefined, String(val))
}

export function cloneVNode(vnode) {
    const cloned = new VNode(
        vnode.tag, vnode.data, vnode.children && vnode.children.slice(),
        vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory
    )
    return cloned
}